classdef TestTomlRead < matlab.unittest.TestCase

  methods (Test)

    function testReadExample(testCase)
      matl_strct = containers.Map( ...
        {'title', 'owner', 'database', 'servers', 'clients'}, ...
        { ...
          'TOML Example', ...
          containers.Map( ...
            {'name', 'dob'}, ...
            {'Tom Preston-Werner', '1979-05-27T07:32:00-08:00'}, ...
            'UniformValues', false ...
          ), ...
          containers.Map( ...
            {'server', 'ports', 'connection_max', 'enabled'}, ...
            {'192.168.1.1', int64([8001, 8001, 8002]), int64(5000), true} ...
          ), ...
          containers.Map( ...
            {'alpha', 'beta'}, ...
            { ...
              containers.Map({'ip', 'dc'}, {'10.0.0.1', 'eqdc10'}, 'UniformValues', false), ...
              containers.Map({'ip', 'dc'}, {'10.0.0.2', 'eqdc10'}, 'UniformValues', false) ...
            } ...
          ), ...
          containers.Map( ...
            {'data', 'hosts'}, ...
            {{{'gamma', 'delta'}, int64([1, 2])}, {'alpha', 'omega'}} ...
          ) ...
        } ...
      );

      c_dir = fileparts(fileparts(mfilename('fullpath')));
      example_file = fullfile(c_dir, 'example.toml');

      testCase.verifyEqual(toml.read(example_file), matl_strct, ...
                           'Did not parse example TOML file correctly.')
    end

  end

end